package luogu.dfs;
//P1506 拯救oibh总部

import java.util.Scanner;

/**
 * @author :chenjie
 * @date :Created 2022/12/22 12:55
 */
public class SaveTHEOibhHeadquarters {
    static boolean[][]st=new boolean[510][510];
    static int count=0;
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        sc.nextLine();
        char[][]chars=new char[n][];
        for (int i = 0; i < n; i++) {
            chars[i]=sc.nextLine().toCharArray();
        }
        int sum=0;
        for (int i = 0; i < n; i++) {
            if(chars[i][0]=='0'){
                dfs(chars,i,0);
            }
            if(chars[i][m-1]=='0'){
                dfs(chars,i,m-1);
            }
        }
        for (int i = 0; i < m; i++) {
            if(chars[0][i]=='0'){
                dfs(chars,0,i);
            }
            if(chars[n-1][i]=='0'){
                dfs(chars,n-1,i);
            }
        }
//        for (int i = 0; i < n; i++) {
//            System.out.println(Arrays.toString(chars[i]));
//        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(chars[i][j]=='0'){
                    sum++;
                }
            }
        }
//        System.out.println(count);
        System.out.println(sum);
    }
    public static void dfs(char[][]chars,int x,int y){
        count++;
        chars[x][y]='1';
        st[x][y]=true;
        int[]dx={0,0,1,-1};
        int[]dy={1,-1,0,0};
        for (int i = 0; i < 4; i++) {
            int a=x+dx[i],b=y+dy[i];
            if(a>=0&&a<chars.length&&b>=0&&(!st[a][b])&&b<chars[a].length&&chars[a][b]!='*'){
                dfs(chars,a,b);
            }
        }
    }
}
